import { mapGetters, mapState } from 'vuex'
export default {
  data () {
    return {
      tabList: [
        {
          key: 'ETH',
          text: 'ETH',
          active: true
        },
        {
          key: 'USDT',
          text: 'USDT',
          active: false
        },
        {
          key: 'BTC',
          text: 'BTC',
          active: false
        },
        {
          key: 'self',
          text: '自选',
          active: false,
          needI18n: true
        }
      ],
      activeIndex: 0
    }
  },
  computed: {
    ...mapState({
      currency: ({ currency }) => currency,
      coinPairInfo: ({ market }) => market.coinPairInfo,
      realTimeQuotes: ({ market }) => market.realTimeQuotes
    }),
    ...mapGetters({
      realTimeQuotesBySymbol: 'market/realTimeQuotesBySymbol',
      realTimeQuotesByType: 'market/realTimeQuotesByType'
    }),
    listData () {
      const key = this.tabList[this.activeIndex].key
      if (this.realTimeQuotesByType[key]) {
        return this.realTimeQuotesByType[key]
      }
      return this.realTimeQuotesBySymbol[key]
    }
  },
  methods: {
    handleClick (index) {
      this.tabList[this.activeIndex].active = false
      this.tabList[index].active = true
      this.activeIndex = index
    }
  }
}
